﻿Imports Model
Imports Model.Midline
Imports Model.Geometry

Public Module BaseAccess


    ''' <summary>
    ''' 判断点在直线的哪一侧,右侧返回True,反之返回False
    ''' </summary>
    ''' <param name="ML">要判断的直线</param>
    ''' <param name="pt">要判断的点</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function isOnRightofLine(ByVal ML As Mid_Line, ByVal pt As Point3d) As Boolean
        Dim spt = ML.startpt
        Dim ept = ML.endpt
        Dim Sabc = (spt.p_x - pt.p_x) * (ept.p_y - pt.p_y) - (spt.p_y - pt.p_y) * (ept.p_x - pt.p_x)
        If Sabc > 0 Then
            Return False
        Else
            Return True
        End If
    End Function
    ''' <summary>
    ''' 判断点在直线的哪一侧,右侧返回True,反之返回False
    ''' </summary>
    ''' <param name="vec">要判断的方向</param>
    ''' <param name="spt" >向量起点</param>
    ''' <param name="pt">要判断的点</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function isOnRightofLine2(ByVal vec As SingleVector, ByRef spt As Point3d, ByVal pt As Point3d) As Boolean
        Dim Sabc = vec.V_x * (pt.p_y - spt.p_y) - vec.V_y * (pt.p_x - spt.p_x)
        If Sabc > 0 Then
            Return False
        Else
            Return True
        End If
    End Function


    ''' <summary>
    ''' 弧度转角度
    ''' </summary>
    ''' <param name="rad"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function RadToDegree(ByRef rad As Double) As Double
        Return 180 * rad / (Math.PI)
    End Function
    ''' <summary>
    ''' 角度转弧度
    ''' </summary>
    ''' <param name="degree"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function DegreeToRad(ByRef degree As Double) As Double
        Return Math.PI * degree / 180
    End Function

End Module
